<!-- daterange picker -->
<link rel="stylesheet" href="__PUBLIC__/AdminLTE/plugins/daterangepicker/daterangepicker.css">
<style>
    a.remark_area {
        display: block;
    }
</style>
<div class="content-wrapper">
    <section class="content-header">
        <h1>订单报价</h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">订单管理</li>
            <li class="active">订单报价</li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-header with-border">
                <form class="form-inline" action="/admin/order/waitQuotedOrderList" method="get">
                    <div class="form-group">
                        <label for="company_name">客户名称 </label>
                        <input type="text" class="form-control" id="company_name" name="company_name" placeholder="客户名称" value="{$company_name}">
                    </div>
                    <div class="form-group">
                        <label for="department_id" class="control-label">部门 </label>
                        <select id="department_id" class="form-control" name="department_id">
                            <option value="0">请选择</option>
                            <foreach name="departmentList" item="department">
                                <option value="{$department.id}" <if condition="$department.id eq $department_id ">selected</if>>{$department.name}</option>
                            </foreach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="admin_name">部门人员 </label>
                        <input type="text" class="form-control" id="admin_name" name="admin_name" placeholder="部门人员" value="{$admin_name}">
                    </div>
                    <button type="submit" class="btn btn-info" id="save-btn">查询</button>
                </form>
            </div>
            <div class="box-body table-responsive">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <th style="width: 80px">ID</th>
                        <th>订单ID</th>
                        <th>客户类型</th>
                        <th>客户名称</th>
                        <th>分类</th>
                        <th>推广产品</th>
                        <th>部门</th>
                        <th>部门人员</th>
                        <th>状态</th>
                        <th>接收时间</th>
                        <th>备注信息</th>
                        <th>操作</th>
                    </tr>
                    <if condition="count($orderList) eq 0"><tr><td class="text-center" colspan="12">暂无数据...</td></tr></if>
                    <foreach name="orderList" item="order">
                        <tr>
                            <td>{$order.order_id}</td>
                            <td>{$order.order_code}</td>
                            <td>{$order.customer_type}</td>
                            <td>{$order.company_name}</td>
                            <td>{$order.category_name}</td>
                            <td>{$order.product_name}</td>
                            <td>{$order.department_name}</td>
                            <td>{$order.admin_name}</td>
                            <td><p class="text text-danger">{$order.status_desc}
                                <if condition="$order.status eq 35 ">
                                    <if condition="$order.dp_manager_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                    <elseif condition="$order.status eq 40 " />
                                    <if condition="$order.director_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                    <elseif condition="$order.status eq 45 " />
                                    <if condition="$order.g_manager_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                </if>
                            </p>
                            </td>
                            <td>{$order.deal_time}</td>
                            <td>
                                <if condition="$order.quote_remark neq ''">
                                    <a href="javascript:void(0)" id="t_remark_{$order.order_id}" class="remark_area" onclick="return remarkInfo('{$order.order_id}')">{$order.quote_remark}</a>
                                    <else />
                                    <button class="btn btn-danger btn-xs" type="button" onclick="return remarkInfo('{$order.order_id}')">添加备注</button>&nbsp;
                                </if>
                            </td>
                            <td style="width: 130px">
                                <php>if($order['status']<55){</php>
                                <button class="btn btn-success btn-xs" type="button" onclick="window.location.href='/admin/order/quotedOrderItemList?order_id={$order.order_id}'"><i class="fa fa-send-o"></i>&nbsp;报价</button>&nbsp;
                                <button class="btn btn-primary btn-xs" type="button" onclick="window.location.href='/admin/order/quotedOrderItemList?order_id={$order.order_id}'"><i class="fa fa-calendar-minus-o"></i>&nbsp;排期</button>&nbsp;
                                <php>}</php>
                                <button class="btn bg-maroon btn-xs " type="button" onclick="window.location.href='/admin/order/orderDetail?id={$order.order_id}'">详情</button>&nbsp;
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
            <div class="box-footer clearfix">{$page_html}</div>
        </div>
    </section>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">添加备注</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <form role="form" class="form-horizontal" action="javascript:;" method="post">
                        <div class="form-group">
                            <label id="control-label" class="control-label col-sm-2">添加备注</label>
                            <div class="col-sm-9">
                                <input type="hidden" id="order_id" name="order_id" value="">
                                <textarea class="form-control" rows="3" id="quote_remark"></textarea>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary save-remark">确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<script>
    function remarkInfo(odrid) {
        var t_remark = $("#t_remark_"+odrid).text();
        if(t_remark.length != 0){
            $("#myModalLabel").text('修改备注');
            $("#control-label").text('修改备注');
            $("#quote_remark").val(t_remark);
        }else{
            $("#quote_remark").val('');
        }
        $("#order_id").val(odrid);
        $("#myModal").modal('show');
    }

    $(".save-remark").click(function () {
        $("#myModal").modal('hide');
        var order_id = $("#order_id").val();
        var t_remark = $("#t_remark_"+order_id).text();
        var quote_remark = $("#quote_remark").val();
        if(t_remark.length != 0 && t_remark == quote_remark){
            ArtDialogHlp.showInfo('提示', '没有任何更改');
            return false;
        }
        var type = 'quote';
        $.post('/admin/order/ajaxOrderRemark',{
            type: type,
            order_id: order_id,
            remark: quote_remark
        },function (_data) {
            if(_data.Code ==999) {
                ArtDialogHlp.showInfo('提示',"备注成功",function () {
                    window.location.reload(true);
                });
            }else{
                ArtDialogHlp.showInfo('提示',_data.Msg);
                return false;
            }
        },"JSON");
    });
</script>